*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --body-bg: #fff;
    --color: #393f46;
    --primary-color: var(--body-bg);
    --primary-bg: #0d6efd;
    --primary-hover-bg: #0b5ed7;
    --secondary-color: var(--body-bg);
    --secondary-bg: #1d9f0a;
    --secondary-hover-bg: #107e00;
    --box-bg: #e9ecef;
    --box-hover-color: #0a58ca;
    --box-hover-bg: #dee2e6;
    --box-active-bg: #d7ecfa;
    --box-active-outline-bg: #37a0e6;
    --form-control-bg: var(--body-bg);
    --form-control-border-color: #ced4da;
    --controls-bg: var(--body-bg);
    --controls-border-color: var(--shadow-color-mid);
    --button-disabled-color: #ccc;
    --icon-bagde-new-text: 'NEW';
    --icon-bagde-new-bg: #007d00;
    --icon-bagde-local-text: 'LOCAL';
    --icon-bagde-local-bg: #800072;
    --icon-bagde-not-local-text: 'SUBSET';
    --icon-bagde-not-local-bg: #002080;
    --dialogbox-bg: var(--body-bg);
    --dialog-export-color: var(--color);
    --dialog-export-bg: var(--body-bg);
    --shadow-color-deep: rgba(0, 0, 0, 0.5);
    --shadow-color-mid: rgba(0, 0, 0, 0.2);
    --shadow-color-light: rgba(0, 0, 0, 0.05);
    scroll-behavior: smooth;
}

html {
    width: 100%;
    height: 100%;
}

body {
    overflow-x: hidden;
    margin: 0;
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.4;
    background-color: var(--body-bg);
    color: var(--color);
}

button, input, optgroup, select, textarea {
    margin: 0;
    font-family: inherit;
}

.form-control {
    display: block;
    width: 100%;
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: inherit;
    background-color: var(--form-control-bg);
    background-clip: padding-box;
    border: 1px solid var(--form-control-border-color);
    appearance: none;
    border-radius: .375rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

#iconContainer {
    display: grid;
    padding: 1rem;
    justify-content: space-between;
    grid-template-columns: repeat(auto-fill, 160px);
    grid-auto-rows: max-content;
    gap: 1.5rem 1rem;
}

.ui-icon {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

#controls {
    position: sticky;
    display: flex;
    justify-content: end;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 1rem;
    top: 0;
    left: 0;
    background-color: var(--controls-bg);
    border-bottom: 1px solid var(--controls-border-color);
    box-shadow: 0 10px 30px 0 var(--shadow-color-light);
    z-index: 1;
}
#controls label {
	user-select: none;
}

.section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.file {
    max-width: 250px;
}
.file > label {
    font-weight: 600;
}
.file-input {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
}

.section.buttons button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.filter {
    margin-left: auto;
    flex-flow: row;
}
#filter_text {
    min-width: 10rem;
    flex-grow: 1;
}

.icon {
	position: relative;
	text-align: center;
}
.icon.hide {
	display: none;
}
.icon.badge::after {
	content: '';
	position: absolute;
	display: inline-block;
	top: -7px;
	right: -8px;
	color: var(--body-bg);
	padding: 2px 7px;
	border-radius: 50em;
	font-size: 10px;
    font-weight: 600;
}
.icon.new::after {
    content: var(--icon-bagde-new-text);
    background-color: var(--icon-bagde-new-bg);
}
.icon.only-local::after {
    content: var(--icon-bagde-local-text);
    background-color: var(--icon-bagde-local-bg);
}
.icon.not-local::after {
    content: var(--icon-bagde-not-local-text);
    background-color: var(--icon-bagde-not-local-bg);
}
.icon span {
	font-size: 0.875em;
}

.symbol {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    background-color: var(--box-bg);
    user-select: none;
}
.symbol:hover {
    background-color: var(--box-hover-bg);
    color: var(--box-hover-color);
    cursor: pointer;
}
.symbol svg {
	width: 32px;
	height: auto;
}
.icon.selected .symbol {
    outline: 2px solid var(--box-active-outline-bg);
    background-color: var(--box-active-bg);
}

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: var(--primary-bg);
    color: var(--primary-color);
    text-decoration: none;
    font-size: inherit;
    font-weight: 400;
    border-radius: 6px;
    transition: background-color 0.12s ease, box-shadow 0.12s ease;
    border: none;
    cursor: pointer;
}
.btn:hover {
    background-color: var(--primary-hover-bg);
}
.btn:active {
    background-color: var(--primary-bg);
    box-shadow: inset 0 3px 5px var(--shadow-color-mid);
}
.btn:disabled {
    background-color: var(--button-disabled-color) !important;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}
.btn.secondary {
    background-color: var(--secondary-bg);
    color: var(--secondary-color);
}
.btn.secondary:hover {
    background-color: var(--secondary-hover-bg);
}
.btn.secondary:active {
    background-color: var(--secondary-bg);
}

#dialogBox.hidden {
    display: none !important;
}
#dialogBox .title-bar {
    display: flex;
    justify-content: space-between;
}
#dialogBox .title-bar .title {
    font-weight: 600;
    font-size: 1.2rem;
}
.dialog-overlay {
    position: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--shadow-color-deep);
    z-index: 1000;
}
.dialog-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 95vw;
    height: 95vh;
    padding: 20px;
    background-color: var(--dialogbox-bg);
    border-radius: 8px;
    box-shadow: 0 5px 15px var(--shadow-color-deep);
}
#dialogMessage {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    height: 100%;
}
.dialog-box .download-message {
    font-size: 0.8rem;
}
.download-message a:visited, .download-message a:link {
    color: var(--color);
}
#dialogExport {
    flex-grow: 1;
    padding: 0.2rem 0.5rem;
    color: var(--dialog-export-color);
    background-color: var(--dialog-export-bg);
}
#closeDialogBtn {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.35rem 0.5rem;
    background-color: var(--box-bg);
    color: var(--color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#closeDialogBtn:hover {
    background-color: var(--shadow-color-deep);
}

@media (max-width: 1410px) {
    .file {
        max-width: 180px;
    }
}

@media (max-width: 1200px) {
    #controls {
        flex-wrap: wrap;
    }

    .section.buttons {
        margin-inline-start: auto;
    }

    .section.filter {
        margin: 0;
        width: 100%;
    }
}

@media (max-width: 840px) {
    #controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .section {
        width: 100%;
    }

    .file {
        max-width: unset;
        flex-grow: 1;
    }

    .btn {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 630px) {
    #controls {
        flex-direction: row;
        justify-content: space-between;
    }

    .section.files {
        display: inline-flex;
        flex-direction: column;
        width: auto;
    }
    .file {
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        gap: 0.5rem;
        flex-grow: 0;
    }
    .file-input {
        max-width: 200px;
        margin-top: 0;
    }

    .section.buttons {
        display: inline-flex;
        flex-direction: column;
        gap: 0.5rem;
        width: auto;
        margin-inline-start: 0;
    }
}

@media (max-width: 580px) {
    .file-input {
        max-width: 180px;
    }
}

@media (max-width: 515px) {
    #controls {
        flex-direction: column;
        justify-content: unset;
    }

    .section.files {
        width: 100%;
    }
    .file-input {
        width: auto;
        max-width: unset;
    }

    .section.buttons {
        width: 100%;
    }

    #filter_text {
        min-width: unset;
    }
}
@media (max-width: 450px) {
    .file {
        flex-direction: column;
        align-items: start;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --body-bg: #212529;
        --color: #bbb;
        --primary-color: var(--color);
        --primary-bg: #0849a8;
        --primary-hover-bg: #0b5ed7;
        --secondary-color: var(--color);
        --secondary-bg: #157307;
        --secondary-hover-bg: #107e00;
        --box-bg: #343a40;
        --box-hover-color: #0d6efd;
        --box-hover-bg: #1c1f24;
        --box-active-bg: #1c1f24;
        --box-active-outline-bg: #0d6efd;
        --form-control-bg: transparent;
        --form-control-border-color: rgba(255, 255, 255, 0.12);
        --controls-bg: var(--box-active-bg);
        --controls-border-color: rgba(255, 255, 255, 0.12);
        --icon-bagde-new-bg: #00b324;
        --icon-bagde-local-bg: #a500b3;
        --icon-bagde-not-local-bg: var(--box-active-outline-bg);
        --dialogbox-bg: var(--box-bg);
        --dialog-export-color: #999;
        --dialog-export-bg: var(--box-active-bg);
    }
}